<template>
  <div>
    <ul>
      <li v-for="(val, index) in arr" :key="index">
        {{ val }}----{{ index }} <button @click="del(index)">删除</button>
      </li>
    </ul>
    <button @click="btn(1, 100)">添加</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [],
    };
  },
  methods: {
    btn(min, max) {
      this.arr.push(Math.floor(Math.random() * (max - min + 1)) + min);
      // console.log(this.arr);
    },
    del(index) {
      // console.log(index);
      this.arr.splice(index, 1);
      // console.log(this.arr);
    },
  },
};
</script>

<style>
</style>